// custom-tab-bar/index.js
Component({
  data: {
        backgroundColor: "#fff",
   		color: "#5E5DA6",
   		selectedColor: "#5E5DA6",
    list: [
      {
        pagePath: "/pages/home/home",
        text: "首页",
        iconPath: "static/Home-two.png",
        selectedIconPath: "static/Home-two.png"
      },
      {
        bulge:true,
        pagePath: "/pages/camera/camera",
        text: "舌面采集",
        iconPath: "/static/shemiancaiji.png",
        selectedIconPath: "/static/shemiancaiji.png"
      },
      {
        pagePath: "/pages/center/canter",
        text: "我的",
        iconPath: "/static/me.png",
        selectedIconPath: "/static/me.png"
      },
    ]
   selected: 0 // 新增，记录当前选中的tab索引
    },
    attached() {
      // 将当前组件实例挂载到全局，方便后续获取
      if (typeof getApp === 'function') {
        getApp().$tabBar = this; 
      }
    },
    methods: {
      switchTab(e) {
        const data = e.currentTarget.dataset;
        const url = data.path;
        const index = data.index;
        wx.switchTab({ url });
        // 更新选中状态
        this.setData({
          selected: index
        });
      },
      // 新增getTabBar接口
      getTabBar() {
        return this;
      }
    }
  });